<template>
  <div class="platformRrules">
    <!-- 头部 -->
    <!-- <div class="top">
      <top-info></top-info>
    </div> -->
    <!-- 中间内容 -->
    <div class="content">
      <div class="tips" @click="goPTDT">平台动态</div>
      <div class="all">
        <span>全部</span>
      </div>
      <!-- 判断是否有数据 -->
      <div v-if="platformRrulesList.length > 0" class="content_list">
        <div
          class="content_text"
          v-for="(item, index) in platformRrulesList"
          :key="index"
        >
          <div class="content_text_left">
            <div class="content_text_img">
              <img :src="item.image" alt="" />
              <!-- <img src="../../assets/images/black.png" alt=""> -->
            </div>
            <div class="content_text_info">
              <div class="tittle">{{ item.title }}</div>
              <div class="tittle_info">
                <div class="tittle_info_text">
                  {{ item.content }}
                </div>
                <div class="notes" @click="goPlatInfo(item.id, item.title)">
                  [详情]
                </div>
              </div>
            </div>
          </div>
          <div class="content_text_time">
            <div class="time">{{ item.createtime }}</div>
            <div class="name">易可易</div>
          </div>
        </div>
      </div>
      <div v-else class="none_list">
        <!-- <span>暂无内容</span> -->
        <NoContent></NoContent>
      </div>
      <!-- 分页 -->
      <div class="pagination">
        <div class="total">共 {{ totalList }} 条</div>
        <my-pagination
          :totalList="totalList"
          :page="page"
          @handleCurrentChange="handleCurrentChange"
        ></my-pagination>
      </div>
    </div>
    <!-- 底部 -->
    <!-- <div class="plat_bottom">
      <home-page-bottom></home-page-bottom>
    </div> -->
  </div>
</template>

<script setup>
// import topInfo from "../../components/topInfo.vue";
// import homePageBottom from "../../components/homePageBottom.vue";

import { onMounted, ref } from "vue";
//分页组件
import myPagination from "../../../components/pagination.vue";
import NoContent from "../../../components/NoContent.vue";
import { useRouter } from "vue-router";
import { PlatformInfo } from "../../../api/platform";
const router = useRouter();
defineProps({
  msg: String,
});
//获取数据
onMounted(() => {
  getPlatformDynamicsList();
});
//数据总条数
const totalList = ref(0);
const page = ref(1);
const pagesize = ref(10);
const type = ref(2);

const handleSizeChange = (val) => {
  console.log(`${val} items per page`);
};
// 翻页
const handleCurrentChange = (val) => {
  console.log("val", val);
  page.value = val;
  getPlatformDynamicsList(page.value, pagesize.value, type.value);
};
const platformRrulesList = ref([]);
const getPlatformDynamicsList = () => {
  PlatformInfo(page.value, pagesize.value, type.value).then((res) => {
    totalList.value = res.data.total;
    platformRrulesList.value = res.data.data;
  });
};

//动态详情跳转
const goPlatInfo = (id, title) => {
  console.log("id:" + id, "title:" + title);
  router.push({
    path: "/plat-form-dynamicsInfo",
    query: {
      id: id,
      tittle: title,
    },
  });
};
const goPTDT = () => {
  router.push("/plat-form-dynamics");
};
</script>

<style scoped lang="less">
/* .read-the-docs {
  color: #000;
} */
.platformRrules {
  display: flex;
  flex-direction: column;
  // border: 1px solid red;
  // height: 100%;
  width: 100%;
  background: #f5f5f5;
  border-radius: 0px 0px 0px 0px;
  .top {
    // border: 1px solid green;
    margin: 0 auto;
    background-color: #fff;
    width: 100%;
  }
  .content {
    // border: 1px solid red;
    width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    // 没有数据
    .none_list {
      height: calc(100vh - 438px);
      background: #ffffff;
      border-radius: 0px 0px 0px 0px;
      opacity: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      span {
        font-size: 22px;
        font-family: PingFang SC-Medium, PingFang SC;
        font-weight: 500;
        color: rgba(0, 0, 0, 0.87);
      }
    }
    .tips {
      height: 56px;
      line-height: 56px;
      border-radius: 0px 0px 0px 0px;
      opacity: 1;
      font-size: 14px;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: rgba(0, 0, 0, 0.87);
      cursor: pointer;
    }
    .all {
      height: 65px;
      background: #ffffff;
      border-radius: 0px 0px 0px 0px;
      opacity: 1;
      border: 1px solid #e6e6e6;
      span {
        display: inline-block;
        width: 150px;
        height: 63px;
        line-height: 63px;
        border-radius: 0px 0px 0px 0px;
        opacity: 1;
        border-bottom: 2px solid #2487e8;
        text-align: center;
        font-size: 18px;
        font-family: PingFang SC-Bold, PingFang SC;
        font-weight: bold;
        color: #2487e8;
      }
    }
    .content_list {
      min-height: calc(100vh - 438px);
      background-color: #fff;
    }
    .content_text {
      background-color: #fff;
      // box-sizing: border-box;
      height: 98px;
      border-radius: 0px 0px 0px 0px;
      padding: 14px 16px;
      // border: 1px solid red;
      display: flex;
      justify-content: space-between;
      border-bottom: 1px solid #e6e6e6;
      .content_text_left {
        display: flex;
        align-items: center;
        // justify-content: center;
        flex: 1;
        .content_text_img {
          width: 147px;
          height: 98px;
          border-radius: 0px 0px 0px 0px;
          opacity: 1;
          // border: 1px solid green;
          img {
            height: 100%;
            width: 100%;
          }
        }
        .content_text_info {
          display: flex;
          flex-direction: column;
          margin-left: 12px;
          height: 100%;
          flex: 1;
          .tittle {
            height: 31px;
            font-size: 22px;
            font-family: PingFang SC-Bold, PingFang SC;
            font-weight: bold;
            color: rgba(0, 0, 0, 0.87);
            line-height: 31px;
            margin-top: 14px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 1;
            -webkit-box-orient: vertical;
          }
          .tittle_info {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 15px;
            .tittle_info_text {
              height: 22px;
              font-size: 16px;
              font-family: PingFang SC-Medium, PingFang SC;
              font-weight: 500;
              color: rgba(0, 0, 0, 0.87);
              line-height: 22px;
              overflow: hidden;
              text-overflow: ellipsis;
              display: -webkit-box;
              -webkit-line-clamp: 1;
              -webkit-box-orient: vertical;
              flex: 1;
            }
            .notes {
              width: 64px;
              height: 22px;
              font-size: 16px;
              font-family: PingFang SC-Bold, PingFang SC;
              font-weight: bold;
              color: #2487e8;
              line-height: 22px;
              cursor: pointer;
            }
          }
        }
      }
      .content_text_time {
        // border: 1px solid red;
        display: flex;
        box-sizing: border-box;
        padding-top: 60px;
        width: 343px;
        justify-content: flex-end;
        .time {
          height: 22px;
          font-size: 16px;
          font-family: PingFang SC-Medium, PingFang SC;
          font-weight: 500;
          color: rgba(0, 0, 0, 0.87);
          line-height: 22px;
        }
        .name {
          height: 22px;
          font-size: 16px;
          font-family: PingFang SC-Medium, PingFang SC;
          font-weight: 500;
          color: rgba(0, 0, 0, 0.87);
          line-height: 22px;
          margin-left: 63px;
        }
      }
    }
    .pagination {
      height: 62px;
      padding: 0 16px;
      background: #ffffff;
      border-radius: 0px 0px 0px 0px;
      opacity: 1;
      border: 1px solid #e6e6e6;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .total {
        height: 22px;
        font-size: 14px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #606266;
        line-height: 22px;
      }
    }
  }
  .plat_bottom {
    margin-top: 25px;
  }
}
</style>
